<?

class FileFactory
{
    function FileFactory($m_e = false) {
        if (!$m_e) {
            trigger_error('Can\'t be instanted directly - use FileFactory::getInstance() instead');
        }
    }

    function &getInstance() {
        $key = '__file_factory_pattern_singleton_key__';
        if (!(array_key_exists($key, $GLOBALS) && is_object($GLOBALS[$key]) && 'FileFactory' == get_class($GLOBALS[$key]) )) {
            $GLOBALS[$key] =& new FileFactory(true);
        }
        return $GLOBALS[$key];
    }

    function getFile($name) {
        if (file_exists($name)) {
            return new File($name);
        } else {
            return false;
        }
    }

    function getDir($name) {
        if (is_dir($name)) {
            return new Dir($name);
        } else {
            return false;
        }
    }

}

?>